package cm.zhentao.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Result implements Serializable {
    private Integer code;//状态码
    private String message;//提示信息
    private Object obj;//数据

    public static Result OK() {
        return new Result(Constant.RESPONSE_CODE_SUCCESS, "操作成功", null);
    }

    public static Result OK(String message) {
        return new Result(Constant.RESPONSE_CODE_SUCCESS, message, null);
    }

    public static Result OK(Object obj) {
        return new Result(Constant.RESPONSE_CODE_SUCCESS, "操作成功", obj);
    }

    public static Result OK(Object obj, String message) {
        return new Result(Constant.RESPONSE_CODE_SUCCESS, message, obj);
    }

    public static Result ERROR() {
        return new Result(Constant.RESPONSE_CODE_ERROR, "操作失败", null);
    }

    public static Result ERROR(Object obj) {
        return new Result(Constant.RESPONSE_CODE_ERROR, "操作失败", obj);
    }

    public static Result ERROR(String message) {
        return new Result(Constant.RESPONSE_CODE_ERROR, message, null);
    }

    public static Result ERROR(String message, Object obj) {
        return new Result(Constant.RESPONSE_CODE_ERROR, message, obj);
    }

    public static Result NO_LOGIN() {
        return new Result(Constant.RESPONSE_CODE_NO_LOGIN, "未登录", null);
    }

    public static Result FORBIDDEN() {
        return new Result(Constant.RESPONSE_CODE_FORBIDDEN, "权限不足，禁止访问", null);
    }
}